Repository navigation
bugfix(render2d): Flush batched 2D draws before they overflow the dynamic buffers - #3487
tintinhamans wants to merge 1 commit into
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the
Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
WalkthroughThe Generals and GeneralsMD 2D renderers now check vertex and index capacity. W3DDisplay supplies expected draw counts during batch setup and flushes and reinitializes a batch when it cannot fit the upcoming draw. Changes2D renderer capacity checks
Priority: Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Bug fix Possibly related PRs
Merge Risk:
|
[Medium impact] The PR appears safe to merge; no actionable defects were found.
|
1bdda9d to
1714002
Compare
1714002 to
fd459dd
Compare
6b298b2 to
d13fd9a
Compare
d13fd9a to
13462fe
Compare
| UnsignedInt lineColor ) | ||
| { | ||
| setup2DRenderState(nullptr, DRAW_IMAGE_ALPHA, FALSE); | ||
| setup2DRenderState(nullptr, DRAW_IMAGE_ALPHA, FALSE, 4, 6); |
There was a problem hiding this comment.
it might help to have some constants for the 4 and 6 instead of magic numbers.
Probably want something like verticesPerQuad etc.
There was a problem hiding this comment.
Done, added named constants for the quad and triangle counts.
13462fe to
c588bcf
Compare
Render2DClass::RenderpassesIndices.Count()toDynamicIBAccessClass, which takes anunsigned short. 65538 indices become 2, the index buffer is locked for 2, and the copy loop writes all 65538.Before batching,
W3DDisplaycalledRenderafter every draw call. With batching,setup2DRenderStatepreviously only flushed when the texture, mode or grayscale changed, so identical draws could accumulate beyond the dynamic buffer limits.Drawable::drawAmmohits this: it draws one pip image per round in the clip, andClipSizeis a plainINI::parseInt. A weapon withShowsAmmoPipsand a clip of 10923 produces 65538 indices, and selecting or hovering the unit can write up to 128 KB past the buffer.DynamicVBAccessClassandDynamicIBAccessClassnow defineMAX_VERTEX_COUNTandMAX_INDEX_COUNT.Render2DClass::Can_Addchecks whether the batch has room for the requested vertices and indices.Each draw supplies its actual geometry counts to
setup2DRenderState, including rotated images and each clock branch. The batch flushes before the next draw would exceed either limit, rather than at half capacity.Renderkeeps a runtime guard against an unsafe buffer copy, because WorldBuilder'sDrawObjectcalls it on its ownRender2DClasswithout this flush.The similar narrowing in
drawRiverWateris handled separately.AI Disclosure: issue identified by Codex Security Cloud and fix implemented with assistance from Opus 5.5